class AdminController < ApplicationController
  def index
  end

  def home
   # @user = current_user
    #if (@user != "admin")
     # redirect_to admin_index_path
    #end   
  end

  def create
  end

  def book
    @books = Book.order("id").page(params[:page]).per(15)
  end

  def borrow
     @borrows = Kaminari.paginate_array(BorrowItem.all).page(params[:page]).per(15)
  end

  def user
    @users = User.order("id").page(params[:page]).per(15)
  end

  def return
    @borrow_item = BorrowItem.find(params[:item])
    @borrow_item.is_return = true;
    @borrow_item.save
    redirect_to params[:path]
  end
  
  def categories
    @categories = Category.order("id").page(params[:page]).per(1)
  end
  
  def remind
    @item = BorrowItem.find(params[:item])
    UserMailer.remind(@item.user, @item.book, @item.created_at + 7.days).deliver
    redirect_to params[:path]
  end
end
